﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using T6.Models;

namespace T6.Controllers
{
    public class HomeController : Controller
    {
        // GET: Home
        public ActionResult Index()
        {
            using(fashionshoppingDBEntities db=new fashionshoppingDBEntities())
            {
                return View(db.Product.ToList());

            }
            
        }
        public ActionResult login()
        {
            return View();
        }

        public ActionResult login(Users users)
        {
            using (fashionshoppingDBEntities db=new fashionshoppingDBEntities())
            {
                if (ModelState.IsValid)
                {
                    User login = db.Users.FirstOrDefault(u => u.email && u.pwd == User.pwd);
                    if (login == null)
                    {
                        ModelState.AddModelError("", "邮箱或者密码有误");
                    }
                    else
                    {
                        return RedirectToAction("Index")
                    }
                }
            }
            return View();
        }
    }
}